package com.info;

import java.util.Hashtable;


public class ItemInfo implements InfoIf{

	
	protected EquipmentSlotEnum itemSlot;
	protected String name;
	protected String description;
	protected int weight;
	protected Hashtable<BonusTypeEnum, BonusInfo> bonus;
	
	public ItemInfo(){
		this.bonus = new Hashtable<BonusTypeEnum, BonusInfo>();
	}
	
	public void setWeight(int weight){
		this.weight = weight;
	}
	
	public int getWeight(){
		return this.weight;
	}
	
	public void addItemBonus(BonusTypeEnum type, BonusInfo info){
		this.bonus.put(type, info);
	}
	
	public void setItemSlot(EquipmentSlotEnum itemSlot) {
		this.itemSlot = itemSlot;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public EquipmentSlotEnum getItemSlot(){
		return itemSlot;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public String getDescription() {
		return description;
	}


	@Override
	public BonusInfo getBonus(Object info, String condition) {
		if (!bonus.containsKey(info)){
			return BonusInfo.NO_BONUS;
		}
		BonusInfo bonusInfo = bonus.get(info);
		if (bonusInfo instanceof ConditionalBonusInfo){
			ConditionalBonusInfo c = (ConditionalBonusInfo)bonusInfo;
			if (c.getCondition() == null && condition == null){
				return bonusInfo;
			}else if ((c.getCondition() == null && condition != null)){
				return BonusInfo.NO_BONUS;
			}else if (!c.getCondition().equals(condition)){
				return BonusInfo.NO_BONUS;
			}
		}
		return bonusInfo;
	}
}
